from fastapi.logger import logger

from fastapi import FastAPI

# from apps.utils.database import init_db
from apps.utils.events import create_start_app_handler, create_stop_app_handler
from apps.utils.router import init_router
from apps.utils.log import set_logger_handle
from apps.utils.exception import register_exception
from apps.utils.middleare import register_middleware


def init_app(app: FastAPI):
    # init_db(app)
    init_router(app)
    set_logger_handle(app)
    register_exception(app)
    register_middleware(app)
    # 添加事件
    app.add_event_handler("startup", create_start_app_handler(app))
    app.add_event_handler("shutdown", create_stop_app_handler(app))
